package com.example.project.base;

import java.io.Serializable;

public class ResultBean<T> implements Serializable {
    /** 成功 */
    public static final int SUCCESS = 0;
    /** 失败*/
    public static final int FAIL = 1;

    private static final long serialVersionUID = 1L;

    private int code = SUCCESS;
    private String msg = "success";
    private T data;

    public ResultBean(){};
    public ResultBean(T data) {
        super();
        this.data = data;
    }

    public ResultBean(Throwable e) {
        super();
        this.msg = e.getMessage();
        this.code = FAIL;
    }


    public ResultBean(int code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public ResultBean setCode(int code) {
        this.code = code;
        return this;
    }

    public String getMsg() {
        return msg;
    }

    public ResultBean setMsg(String msg) {
        this.msg = msg;
        return this;
    }


    public T getData() {
        return data;
    }

    public ResultBean setData(T data) {
        this.data = data;
        return this;
    }
}
